package com.chushouya.common.constant;

import java.util.Objects;

/**
 * 系统内置参数
 * checking system configs is existed when project starting，if not exist init db and load to cache
 */
public enum SystemConfigEnum {

    SUPER_ADMIN_ID_LIST("super_admin_id_list", ConfigTypeEnum.text, "超级管理员ID配置","100000", "多个超级管理员时,用英文','分隔"),
    ADMIN_USER_DEFAULT_PASSWORD("admin_user_default_password", ConfigTypeEnum.text, "admin用户默认密码", "123456", "重置后的密码"),
    PLATFORM_ROLE_ID("platform_role_id", ConfigTypeEnum.integer, "平台角色的ID", "100000", "平台角色的ID"),
    defaultPlatformServiceRate("default_platform_service_rate", ConfigTypeEnum.decimal, "平台默认服务费","0.02", "平台默认服务费"),
    defaultPlatformLogisticsCost("default_platform_logistics_cost", ConfigTypeEnum.decimal, "平台默认邮费","15", "平台默认邮费"),
    ;

    private String configKey;

    private String configName;

    private ConfigTypeEnum configType;

    private String configValue;

    private String remark;

    SystemConfigEnum(String configKey, ConfigTypeEnum configType, String configName, String configValue, String remark) {
        this.configKey = configKey;
        this.configType = configType;
        this.configName = configName;
        this.configValue = configValue;
        this.remark = remark;
    }

    public String getConfigKey() {
        return configKey;
    }

    public void setConfigKey(String configKey) {
        this.configKey = configKey;
    }

    public String getConfigName() {
        return configName;
    }


    public String getConfigValue() {
        return configValue;
    }

    public String getRemark() {
        return remark;
    }

    public ConfigTypeEnum getConfigType() {
        return configType;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public static SystemConfigEnum getByConfigKey(String configKey) {
        for (SystemConfigEnum thisEnum : SystemConfigEnum.values()) {
            if (Objects.equals(thisEnum.configKey, configKey)) {
                return thisEnum;
            }
        }
        return null;
    }
}
